package com.example.demo.solon.plugin;

import com.example.demo.solon.plugin.controller.DemoController;
import org.noear.solon.Solon;
import org.noear.solon.core.AppContext;
import org.noear.solon.core.Plugin;

/**
 * @author airhead
 */
public class DemoSolonPlugin implements Plugin {
  private AppContext context;

  @Override
  public void start(AppContext context) throws Throwable {
    this.context = context;

    // 简单起见，直接扫描插件所在包，可以根据实际的需要进行定制化的加载
    this.context.beanScan(DemoSolonPlugin.class);
  }

  @Override
  public void prestop() throws Throwable {
    Plugin.super.prestop();
  }

  @Override
  public void stop() throws Throwable {
    // 移除http处理，对于 H-Spi 来说非常重要
    //    Solon.app().router().remove("/hello");
    Solon.app().router().remove(DemoController.class);
  }
}
